/**
 * SvrParamsServiceImpl.java
 * Created at 2017-8-8
 * Created by xieshuang
 * Copyright (C) 2017 BROADTEXT SOFTWARE, All rights reserved.
 */
package com.broadtext.rms.basic.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.broadtext.common.exp.DaoException;
import com.broadtext.common.exp.ServiceException;
import com.broadtext.common.repository.EntityDao;
import com.broadtext.common.service.impl.EntityServiceImpl;
import com.broadtext.common.utils.UUIDUtils;
import com.broadtext.rms.basic.model.TtFtpParams;
import com.broadtext.rms.basic.model.TtSvrParams;
import com.broadtext.rms.basic.service.ISvrParamsService;

/**
 * <p>
 * ClassName: SvrParamsServiceImpl
 * </p>
 * <p>
 * Description: FTP参数配置服务实现类
 * </p>
 * <p>
 * Author: xieshuang
 * </p>
 * <p>
 * Date: 2017-8-8
 * </p>
 */
@Service("svrParamsService")
public class SvrParamsServiceImpl extends EntityServiceImpl<TtSvrParams>
		implements ISvrParamsService {

	/**
	 * <p>
	 * Description: 注解入相关DAO
	 * </p>
	 * 
	 * @param entityDao
	 */
	@Autowired
	@Qualifier("ftpParamsDao")
	public void setEntityDao(EntityDao<TtSvrParams> entityDao) {
		super.entityDao = entityDao;
	}

	/**
	 * 
	 * <p>
	 * Description: 新增or编辑
	 * </p>
	 * 
	 * @param t
	 *            对象
	 * @param currentUser
	 *            当前登录人
	 * @return 保存标志
	 * @throws ServiceException
	 *             异常
	 * @throws DaoException
	 *             异常
	 */
	public void saveOrUpdate(TtSvrParams t, String currentUser)
			throws ServiceException {
		// 返回值
		if (!"".equals(t.getPkId())) {
			// 编辑
			t.setUpdateUser(currentUser);
			t.setUpdateDate(new Date());
			this.updateRecord(t);

		} else {
			// 新增
			t.setPkId(UUIDUtils.getUUID());
			t.setCreateUser(currentUser);
			t.setCreateDate(new Date());
			t.setUpdateUser(currentUser);
			t.setUpdateDate(new Date());
			t.setDelFlag("0");
			this.insertRecord(t);
		}
	}

	/**
	 * 
	 * <p>
	 * Description: 批量删除
	 * </p>
	 * 
	 * @param idArray
	 *            ID
	 * @param sysUser
	 *            当前操作用户
	 * @throws ServiceException
	 *             异常
	 */
	@Override
	public void deleteByIds(String[] idArray, String sysUser)
			throws ServiceException {
		for (String id : idArray) {
			TtSvrParams model;
			model = new TtSvrParams();
			model.setPkId(id);
			model.setDelFlag("1");
			model.setUpdateUser(sysUser);
			model.setUpdateDate(new Date());
			super.updateRecord(model);
		}
	}

}
